package com.fth.learn.chapter06;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;



/**
 * 课堂作业  数组练习
 * YiMi
 *
 * @author YiMi
 * @version 1.0
 * @date 2023/7/13 10:25
 */

public class classwork {
    public static void question01(){
        double[] arr={2800.5,2900,2750.0,3100};
        Arrays.sort(arr);
        System.out.println("最低价是："+arr[0]);
    }

    public static void question02(){
        Scanner scanner =new Scanner((System.in));
        System.out.println("请输入您的年龄:");
//        int a = scanner.nextInt();
//        switch (a/10){
//            case 0:
//                System.out.println("垂暮之年");break;
//            case 1:
//                System.out.println("志学之年");break;
//            case 2:
//                System.out.println("弱冠之年");break;
//            case 3:
//                System.out.println("而立之年");break;
//            case 4:
//                System.out.println("不惑之年");break;
//            case 5:
//                System.out.println("知命之年");break;
//            case 6:
//                System.out.println("花甲之年");break;
//            case 7:
//                System.out.println("古稀之年");break;
//            case 8:
//                System.out.println("杖朝之年");break;
//            case 9:
//                System.out.println("耄耋之年");break;
//        }
        //在网上找到的方法 试着自己做
        int a = scanner.nextInt()/10;
        if(a>100){
            System.out.println("输入错误");
            return;
        }
        String []d=new String[]{"垂暮之年","志学之年","弱冠之年","而立之年","不惑之年","知命之年","花甲之年","古稀之年","杖朝之年","耄耋之年"};
        System.out.println(d[a]);

    }
    public static void question03(){
        int[] a={ 5, 11, 15, 24, 36, 47, 59, 66};
        int[] b = new int[8];

        for (int i = 0; i < a.length; i++) {
            b[i] = a[a.length-1-i];
        }
        System.out.println(Arrays.toString(b));
    }
    public static void question04(){
        int num=0;
        int[] a = new int[10];
        for(int i=0;i<a.length;i++) {
            a[i] = (int)(Math.random()*90+10);
        }
        System.out.println("生成的随机数数组是:" + Arrays.toString(a));
        for(int j=0;j<a.length;j++){
            if(a[j]>80){
                num++;
            }
        }
        if(num>0){
            System.out.println("有");
        }else {
            System.out.println("没有");
        }

    }

    public static void question06(){
        char[] arr = new char[36];
        for (int i = 0; i < 26; i++) {
            arr[i] = (char)('A'+ i );
        }
        for (int i = 26; i < arr.length; i++) {
            arr[i] = (char)('0' + i - 26 );
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    public static void question07(){
        int num=0;
        System.out.println("请输入十个数：");
        Scanner in = new Scanner(System.in);
        int[] array = new int[10];
        for (int i = 0; i < array.length; i++) {
            array[i] = in.nextInt();
        }
        System.out.println(Arrays.toString(array));

        for(int j=0;j<array.length;j++){
            if(array[j]>80){
                num++;
            }
        }
        if(num>0){
            System.out.println("有");
        }else {
            System.out.println("没有");
        }
    }

    public static void question10(){
        int[] arr = {1,2,3,4,1,1,2,3,4,4,5,5,6,7};

        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        for (int i = 0; i < arr.length; i++) {
            int num=0;
            for (int j = i; j < arr.length; j++) {
                if (arr[j] > 0) {
                    if (arr[i] != arr[j]) {
                        num = j;
                        break;
                    }
                }
            }
            System.out.print(arr[i]);
            i = (num == 0) ? arr.length - 1 : num - 1;

        }

    }





        public static void main(String[] args) {
            question01();
//            question02();
            question03();
            question04();
            question06();
//            question07();
            question10();
    }
}
